package operation;

import book.Book;
import book.BookList;

import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: LXW
 * Date: 2022-05-28
 * Time: 19:34
 */
public class ReturnOperation implements IOperation {
    @Override
    public void work(BookList books) {
        System.out.println("请输入你要归还的图书");
        Scanner scanner = new Scanner(System.in);
        String name = scanner.nextLine();
        int size = books.getSize();
        for(int i = 0; i < size; i++) {
            Book book = books.getBook(i);
            if(name.equals(book.getName())) {
                book.setBorrowed(false);
                System.out.println("归还成功");
                return;
            }
        }
        System.out.println("归还失败");
    }
}
